import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver=webdriver.Chrome()
driver.get('http://101.133.169.100/yuns/index.php')
driver.maximize_window()
#登录账号
driver.find_element_by_link_text('登录').click()
driver.find_element_by_name('username').send_keys('15774014104')
driver.find_element(By.ID,'password').send_keys('199812')
driver.find_element_by_name('submit').click()
time.sleep(1)
#进入购物车
driver.find_element(By.ID,'cart_num').click()
#选择商品
driver.find_element_by_xpath('/html/body/div[3]/div/div[2]/div[1]/div[2]/div[1]/input').click()
#去结算
driver.find_element_by_class_name('gopay').click()
#添加地址
time.sleep(2)
driver.find_element_by_link_text('添加新地址').click()
driver.find_element(By.PARTIAL_LINK_TEXT,'加新地址').click()
time.sleep(3)
driver.find_element_by_id('recive_is_default').click()
driver.find_element_by_name('name').send_keys('梁思德')
driver.find_element_by_name('mobile').send_keys('15774014104')
driver.find_element_by_class_name('area_name').click()
driver.find_element_by_link_text('湖南省').click()
driver.find_element_by_link_text('株洲市').click()
driver.find_element_by_link_text('天元区').click()
driver.find_element(By.ID,'recive_address').send_keys('湖南株洲化工')
driver.find_element_by_link_text('确定').click()
#下单支付
time.sleep(1)
driver.find_element_by_class_name('gopay').click()
time.sleep(3)
driver.quit()